package com.ldr.danmuku

import android.content.Context
import android.util.AttributeSet
import android.widget.LinearLayout
import androidx.core.view.children

/**
 * @author :create by ldr
 * time:2022/12/29 10:35
 * @descript:弹幕的总View在布局中展示
 */
class DanMuLayoutView: LinearLayout{

    constructor(context: Context?): this(context,null)

    constructor(context: Context?, attrs: AttributeSet?): this(context, attrs,0)

    constructor(context: Context?, attrs: AttributeSet?,defStyleAttr:Int): super(context, attrs,defStyleAttr){
        addViewLan()
    }

   lateinit var mLanViewManager:LanViewManager

    /**
     * 添加
     */
    fun addViewLan(){
        mLanViewManager = LanViewManager.singleton
        when(DanMuManager.singleton.mDanMuConfig.mLanScreenType){
            LanScreenType.EXACT_NUMBER ->{
                val number = DanMuManager.singleton.mDanMuConfig.mLanMaxNumber
                for (index in 0 until number){
                    addView(DanMuLaneView(context = context))
                }
            }
            LanScreenType.SCREEN_TOP ->{
                //计算屏幕高度 取三分之一
            }
            LanScreenType.SCREEN_HALF ->{
                //计算屏幕高度 取二分之一
            }
            LanScreenType.SCREEN_FULL ->{
                //计算屏幕高度 取全部
            }
        }
        mLanViewManager.clearLanView()
        children.forEach {
           val danMuLaneView =  it as DanMuLaneView
            mLanViewManager.addLanView(danMuLaneView)
        }
    }


}